//
//  InviatationSearchTypeViewModel.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/11.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "InviatationSearchTypeViewModel.h"
#import "InvitationBaoJiaTableViewCell.h"
#import "InvitationPhoneTableViewCell.h"
#import "OrderOperationView.h"
#import "GLGWPopTosView.h"

@interface InviatationSearchTypeViewModel ()<UITableViewDelegate,UITableViewDataSource>{
    InvitationSearchType selfType;
}

@end

@implementation InviatationSearchTypeViewModel

-(instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView theSearchType:(InvitationSearchType)i_type{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
        selfType = i_type;
        tableView.height = tableView.height - kHeightProportion_In_iPhoneTriploid(88);
        tableView.delegate = self;
        tableView.dataSource = self;
        if (i_type == InvitationSearchType_Phone) {
            tableView.rowHeight = kHeightProportion_In_iPhoneTriploid(170);
        }else{
            tableView.rowHeight = kHeightProportion_In_iPhoneTriploid(140);
        }
        tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kHeightProportion_In_iPhoneTriploid(10))];
        [superView addSubview:tableView];
    }
    return self;
}

#pragma mark -- UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BaseTableViewCell * cell;
    if (selfType == InvitationSearchType_Store) {
        InvitationBaoJiaTableViewCell * cell_Baojia = [InvitationBaoJiaTableViewCell cellWithTableView:tableView];
        cell_Baojia.Block_InviateAction = ^{
            [self createPopView];
        };
        cell = cell_Baojia;
    }else{
        InvitationPhoneTableViewCell * cell_phone = [InvitationPhoneTableViewCell cellWithTableView:tableView];
        cell_phone.Block_PhoneInviate = ^{
            [self createPopView];
        };
        cell = cell_phone;
    }
    return cell;
}

-(void)createPopView{
    OrderOperationView * opeartionView = [[OrderOperationView alloc] initWithPopOrderOperation:@[@"取消",@"确认邀请"] theTitleStr:@"邀请商家" theTosStr:@"小张店铺\n联系电话：188 6460 6968"];
    [opeartionView show];
    opeartionView.Block_CaseAction = ^(NSInteger tag) {
        if (tag == 311) {
            GLGWPopTosView * p_View = [[GLGWPopTosView alloc] initWithPopView:PopViewType_Success];
        }
    };
}

@end
